//
//  ZYCTeaLeaveApplicationBottomView.m
//  ZDSC
//
//  Created by 张威 on 2021/10/21.
//

#import "ZYCTeaLeaveApplicationBottomView.h"
@interface ZYCTeaLeaveApplicationBottomView ()


@end
@implementation ZYCTeaLeaveApplicationBottomView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HEX_RGB(@"#F9F9F9");
        [self addSubview:self.comfirmButton];
        [self.comfirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(240.0f, 40.0f));
        }];
 
    }
    return self;
}

- (UIButton *)comfirmButton {
    if (!_comfirmButton) {
        _comfirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _comfirmButton.frame = CGRectMake(0,0, kScreenWidth - 2 * 66, 40);
        [_comfirmButton setTitle:@"提交" forState:UIControlStateNormal];
        [_comfirmButton setTitleColor:HEX_RGB(kTitleWhiteColor) forState:UIControlStateNormal];
//        _comfirmButton.backgroundColor = HEX_RGB(@"#41B166");
        _comfirmButton.titleLabel.font = kCustomFont(@"PingFangSC-Light", 18.0f);
        [_comfirmButton addTarget:self action:@selector(clickComfirmAction:) forControlEvents:UIControlEventTouchUpInside];
        _comfirmButton.layer.cornerRadius = 20;
        _comfirmButton.layer.masksToBounds = YES;
        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
        gradientLayer.startPoint = CGPointMake(0, 0);
        gradientLayer.endPoint = CGPointMake(1, 0);
        gradientLayer.colors = @[(__bridge id)HEX_RGB(@"#F6EEB0").CGColor,
                                 (__bridge id)HEX_RGB(@"#009B4C").CGColor];
        gradientLayer.locations = @[@(0.3),@(1.0f)];
        gradientLayer.frame = _comfirmButton.bounds;
        gradientLayer.cornerRadius = 20;
        [_comfirmButton.layer insertSublayer:gradientLayer atIndex:0];
    }
    return _comfirmButton;
}

-(void)clickComfirmAction:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(teaLeaveApplicationBottomViewDidComfirm)]) {
        [self.delegate teaLeaveApplicationBottomViewDidComfirm];
    }
}
@end
